package com.lancoo.hanvon.sdk;

import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class SDK_HttpClientHelper {
    public static String postData(String urlStr, String data) {
        StringBuilder sb = new StringBuilder();
        URL url = null;
        HttpURLConnection conn = null;

        try {
            url = new URL(urlStr);
            conn = (HttpURLConnection)url.openConnection();
            conn.setConnectTimeout(60000);
            conn.setReadTimeout(60000);
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/octet-stream");
            conn.getOutputStream().write(data.getBytes("UTF-8"));
            Log.i("HTTP RESPONCE STATUS:", "" + conn.getResponseCode());
            InputStream in = conn.getInputStream();
            BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));

            String line;
            while((line = r.readLine()) != null) {
                sb.append(line);
            }
        } catch (MalformedURLException var12) {
            var12.printStackTrace();
        } catch (IOException var13) {
            var13.printStackTrace();
        } finally {
            if (conn != null) {
                conn.disconnect();
            }

        }

        return sb.toString();
    }
}
